package com.task.submitter.tasks;

public class MembraneShapeData {

	double[][] rGrid;
	double[][] rGridTemp;
	int rDimension;
	double rInitTemp;
	long   rProcessingTime; 
	int    rVerboseLevel;
	
	public MembraneShapeData(int dim, double temperature){
		initArrays(dim);
		initTempDistribution(temperature);
	}
	
	private void initArrays(int dim){
		rDimension = dim;
	    rGrid     = new double[rDimension][];
	    rGridTemp = new double[rDimension][];
	    for (int i = 0; i < rDimension; i++) {
	      rGrid[i]     = new double[rDimension];
	      rGridTemp[i] = new double[rDimension];
	    }
	}
	
	public void initTempDistribution( double temperature ){
	    
	    if ( rDimension > 0){
	      rInitTemp = temperature;
	      for(int j=0;j<rDimension;j++){
	        double x = (double)(j);
	        rGrid[           0][j] = parabola( x, rInitTemp );
	        rGrid[rDimension-1][j] = parabola( x, rInitTemp );
	      }
	    }
	  }
	  
	    
	public double parabola(double x, double max){
	    double x1 = 0;
	    double x2 = (double)(rDimension) -1.;
	    // if (x2 < 1.) // throw "Parabola: ERROR parametr array dim too small"
	    
	    double a = -4*max*Math.pow( 1./x2, 2. );
	    double y  = a*(x-x1)*(x-x2);
	    return y;
	}
	
	public void print(){
		for (int row = 0; row < rDimension; row++) {
		      for (int col = 0; col < rDimension; col++) {
		        System.out.print( rGrid[row][col] + " " );
		      }    
		      System.out.println( " " );
	    }
	}
	
	public double[][] getrGrid() {
		return rGrid;
	}
	public void setrGrid(double[][] rGrid) {
		this.rGrid = rGrid;
	}
	public double[][] getrGridTemp() {
		return rGridTemp;
	}
	public void setrGridTemp(double[][] rGridTemp) {
		this.rGridTemp = rGridTemp;
	}
	public int getrDimension() {
		return rDimension;
	}
	public void setrDimension(int rDimension) {
		this.rDimension = rDimension;
	}
	public double getrInitTemp() {
		return rInitTemp;
	}
	public void setrInitTemp(double rInitTemp) {
		this.rInitTemp = rInitTemp;
	}
	public long getrProcessingTime() {
		return rProcessingTime;
	}
	public void setrProcessingTime(long rProcessingTime) {
		this.rProcessingTime = rProcessingTime;
	}
	public int getrVerboseLevel() {
		return rVerboseLevel;
	}
	public void setrVerboseLevel(int rVerboseLevel) {
		this.rVerboseLevel = rVerboseLevel;
	}
	
}
